package com.gupao.vip.netty;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class EchoClientHandler extends ChannelInboundHandlerAdapter {
    private int counter;

    private static final String ECHO_REQ = "Hi, Majingang. Welcome to Netty. $_";

    public EchoClientHandler(){

    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        for(int i=0; i<10; i++){
            ctx.writeAndFlush(Unpooled.copiedBuffer((ECHO_REQ + counter++).getBytes()));
        }
    }
}
